BrianListProposal
Lists A List is an ordered sequence of values, of any length. List is a parameterized type; the elements of a List must be of type T. Lists may be empty. List-valued variables whose value is null are treated as empty lists. The type specifier for a List in JavaFX code is T[]. List literals are created with the [ value, value, .... ] notation: var a = [ 1, 2, 3 ] // inferred type List var a : Number[] = [ 1, 2, 3 ] // explicit type Lists of numbers can use the range shorthand n..m to mean the numbers from n to m, inclusive: var a = [ 1, 2, 3..100 ] Upconversion and downconversion The type of List is distinct from T and has no super/subtype relationship, but instances are implicitly "upconverted" to lists when a value of type T is assigned to a variable of type List: var a : Number[]; a = 1; // same as a = [ 1 ] function foo(a : Number[]) { ... } foo(1) // same as foo([ 1 ]); Lists are not implicitly downconverted to instance values, but instead are objects with size(), first(), rest(), and last() methods, so that the user can easily choose how to explicitly downconvert from list to instance. Lists are immutable, so operations that modify a list return a new list instead. List element retrieval Elements can be retrieved from a list with the familiar bracket operators: ae. The expression in the brackets can be a Number, a List, or a selection expression. For a List: If the index expression is a Number, then ae is of type T, and the result is the element whose index is e. If e is out of range, an ArrayIndexOutOfBoundsException is thrown. (?) var a = [ 1, 2, 3 ] a0 -> 1 a2 -> 3 a7 -> AIOOBE If the index expression is a List, then ae is of type T[], and the result is a list of elements from a whose indexes are the elements of e. If any elements of e correspond to indexes that are out of range, they are silently ignored. (?) var a = [ 1..100 ] a2, 3 -> 2, 3 a1..1000 -> 1..100 If the index expression is a selection expression of the form [ n | boolean predicate involving n ], then ae is of type T[], and the result is a list of elements which match the predicate. Predicate expressions may contain "indexof n", where n is the induction variable, which represents the index of the element being considered. var a = [ 1.. 100 ] a n > 50 -> 51..100 a indexof n < 5 -> [ 1..5 ] Loops Lists may be used to drive loops: for (i in 1..100) { loop body } Options: The value of a loop expression could be the value of the last iteration, or it could be a list containing the values of all the iterations. The former is like a traditional loop; the latter is a foreach-loop comprehension.